package net.hn.hnms.biz.shipped.request;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Date;
import java.util.List;

/**
 * @author wangjingrui
 * @date 2022/9/1 10:30
 */
@Data
public class TransportDeliveryInfoReq extends BaseReq {

    @ApiModelProperty(value = "结算状态")
    private String settleState;

    @ApiModelProperty(value = "提煤单号")
    private String voucherNo;

    @ApiModelProperty(value = "车牌号")
    private String vehicleNo;

    @ApiModelProperty(value = "承运单位名称")
    private String carrierCompanyName;

    @ApiModelProperty(value = "营业登记状态")
    private String isRegName;

    @ApiModelProperty(value = "营业登记人")
    private String businessEgistrationName;

    @ApiModelProperty(value = "提煤单状态")
    private String state;

    @ApiModelProperty(value = "煤矿编码")
    private String mineCode;

    private List<String> dateTimeRange;

    public Date getBeginDate() {
        if (dateTimeRange != null && dateTimeRange.size() > 0) {
            return StrUtil.isNotBlank(dateTimeRange.get(0)) ? DateUtil.parseDate(dateTimeRange.get(0)) : null;
        }
        return null;
    }

    public Date getEndDate() {
        if (dateTimeRange != null && dateTimeRange.size() > 1) {
            return StrUtil.isNotBlank(dateTimeRange.get(1)) ?DateUtil.parseDate(dateTimeRange.get(1)) : null;
        }
        return null;
    }


    public Date getBeginDateTime() {
        if (dateTimeRange != null && dateTimeRange.size() > 0) {
            return StrUtil.isNotBlank(dateTimeRange.get(0)) ? DateUtil.beginOfDay(DateUtil.parseDate(dateTimeRange.get(0))) : null;
        }
        return null;
    }

    public Date getEndDateTime() {
        if (dateTimeRange != null && dateTimeRange.size() > 1) {
            return StrUtil.isNotBlank(dateTimeRange.get(1)) ? DateUtil.endOfDay(DateUtil.parseDate(dateTimeRange.get(1))) : null;
        }
        return null;
    }

    public Date getBeginTime() {
        if (dateTimeRange != null && dateTimeRange.size() > 0) {
            return StrUtil.isNotBlank(dateTimeRange.get(0)) ? DateUtil.parseTime(dateTimeRange.get(0)) : null;
        }
        return null;
    }

    public Date getEndTime() {
        if (dateTimeRange != null && dateTimeRange.size() > 1) {
            return StrUtil.isNotBlank(dateTimeRange.get(1)) ?DateUtil.parseTime(dateTimeRange.get(1)) : null;
        }
        return null;
    }
}
